/*
package com.example.PersonalAddressBook3.web;


import com.example.PersonalAddressBook.Contact;
import com.example.PersonalAddressBook2.BusinessLogic;
import com.example.PersonalAddressBook2.DataAccess;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/contact")
public class ContactServlet extends HttpServlet {
    private BusinessLogic businessLogic;

    @Override
    public void init() throws ServletException {
        super.init();
        DataAccess dataAccess = new DataAccess();
        businessLogic = new BusinessLogic(dataAccess);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();

        try {
            List<Contact> contacts = businessLogic.listContacts();
            for (Contact contact : contacts) {
                out.println("<p>Name: " + contact.getName() + "</p>");
                out.println("<p>Address: " + contact.getAddress() + "</p>");
                out.println("<p>Phone: " + contact.getPhone() + "</p>");
                out.println("<hr>");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // Handle POST requests here, such as adding or updating contacts.
    }
}*/
